package sytwo;
public class Student {
    private String studentId;    // 学生编号
    private String name;         // 姓名
    private String gender;       // 性别
    private Course selectedCourse; // 所选课程
    // 构造方法
    public Student(String studentId, String name, String gender) {
        this.studentId = studentId;
        this.name = name;
        this.gender = gender;
    }
    // 选课方法
    public void selectCourse(Course course) {
        this.selectedCourse = course;
        System.out.println(name + "同学选了《" + course.getCourseName() + "》课程");
    }
    // 退课方法
    public void dropCourse() {
        if (selectedCourse != null) {
            System.out.println(name + "同学退选了《" + selectedCourse.getCourseName() + "》课程");
            this.selectedCourse = null;
        } else {
            System.out.println(name + "同学未选任何课程，无法退课");
        }
    }
    // 打印课表方法
    public void printSchedule(Teacher teacher) {
        if (selectedCourse != null) {
            System.out.println("==========" + name + "的课表==========");
            System.out.println("编号：" + selectedCourse.getCourseId());
            System.out.println("课程名称：" + selectedCourse.getCourseName());
            System.out.println("上课地点：" + selectedCourse.getLocation());
            System.out.println("上课时间：" + selectedCourse.getTime());
            System.out.println("授课教师：" + teacher.getName());
            System.out.println("==========================");
        } else {
            System.out.println(name + "同学未选任何课程，课表为空");
        }
    }
    // Getter方法
    public String getStudentId() {
        return studentId;
    }
    public Course getSelectedCourse() {
        return selectedCourse;
    }
}